<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 准备好容器 -->
    <div id="test">
    </div>
    <div id="test1">
    </div>
</body>
<!-- 引入依赖 引入的时候，必须就按照这个步骤-->
<script src="../React-js/react.development.js" type = "text/javascript"></script>
<script src = "../React-js/react-dom.development.js" type = "text/javascript"></script>
<script src="../React-js/babel.min.js" type="text/javascript"></script>
<script src="../React-js/prop-types.js" type="text/javascript"></script>

<script type="text/babel">
    
    class Person extends React.Component{
        render(){
            const{name,age,sex} = this.props
            return(
                <ul>
                    <li>姓名：{name}</li>    
                    <li>性别：{sex}</li>    
                    <li>年龄：{age+1}</li>    
                </ul>
            )
        }
    }
    // 对标签属性进行类型，必要性限制
    Person.propTypes={
        name:PropTypes.string.isRequired,
        sex:PropTypes.string,
        age:PropTypes.number,
        speak:PropTypes.func
    }
    // 默认值
    Person.defaultProps= {
        sex:'不男不女'
    }

    ReactDOM.render(<Person name="tom" age={12} sex="男" speak={speak}/>,document.getElementById("test"))
    const p = {name:'jery',age:18,sex:'女'}
    ReactDOM.render(<Person {...p}/>,document.getElementById("test1"))

    function speak(){
        conslole.log('lalala');
    }
</script>
</html>